home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-13 | 1.9 KB | 74 lines | [TEXT/ttxt] |
- class SmallTextEdit ( TextEdit)
- class variables
- defaultWidth:50
- instance variables
- frame:(new Frame)
- _font
- end
-
- ------------------------
- -- parameters to init --
- -- brush: overrides the style's brush
- -- x,y: position for the label
- -- width, height: use this size instead of calculating it from the text
- -- text: the text for the label
- method init self {class SmallTextEdit} #rest args #key \
- boundary: \
- font:(theSystemFont) \
- text:myText("" as Text) \
- fill:(WhiteBrush) \
- ->
- (
-
- if (boundary = unsupplied) do
- boundary := new Rect x2:SmallTextEdit.defaultWidth \
- y2:(font.leading + 6)
- -- bug in TextEdit requires text arg to be Text and not String
- apply nextMethod self boundary:boundary target:(myText as Text)\
- fill:fill stationary:true args
- )
-
- method afterInit self {class SmallTextEdit} #rest args #key \
- font:(theSystemFont) \
- inset:(new Point x:4 y:0) \
- ->
- (
- apply nextMethod self args
- self.cursor := new Rect x2:2 y2:font.leading
- self.font := font
- self.inset := inset
- self.selectionBackground := whiteBrush
- )
-
- method fontGetter self {class SmallTextEdit} -> self._font
- method fontSetter self {class SmallTextEdit} newFont ->
- (
- setDefaultAttr self @font newFont.font
- setDefaultAttr self @size newFont.fontSize
- setDefaultAttr self @leading newFont.leading
- self.cursor := new Rect x1:-1 x2:0 \
- y1:(-newFont.leading + newFont.descent) y2:0
- self._font := newFont
- )
-
- method recalcRegion self {class SmallTextEdit} ->
- (
- nextMethod self
- SetBoundary self.frame self.boundary
- )
-
- method textSetter self {class SmallTextEdit} new_text ->
- (
- self.target := if (isAKindOf new_text Text) then new_text
- else (new_text as Text)
- )
-
- method textGetter self {class SmallTextEdit} -> self.target
-
- method draw self {class SmallTextEdit} surface clip ->
- (
- nextMethod self surface clip -- super (TextPresenter) draws the text
- drawLoweredFrame self.frame surface clip self.globalTransform
- )
-
-